/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

#ifndef CORE_EXCEPTIONS_CLIENTEXCEPTION_H_
#define CORE_EXCEPTIONS_CLIENTEXCEPTION_H_

#include "Exception.h"
#include "ErrorType.h"

namespace aliyun {

namespace exceptions {

class ClientException : public Exception {
 public:
  typedef std::string string;

  ClientException(string errCode, string errMsg, string requestId) {
    errorCode_ = errCode;
    errorMessage_ = errMsg;
    requestId_ = requestId;
  }

  ClientException(string errCode, string errMsg)
      : Exception(errCode + ":" + errMsg) {
    errorCode_ = errCode;
    errorMessage_ = errMsg;
    errorType_ = ErrorType::Client;
  }

  ClientException(string message)
      : Exception(message) {
  }

  const string& getErrorCode() const {
    return errorCode_;
  }

  void setErrorCode(const string& errCode) {
    errorCode_ = errCode;
  }

  const string& getErrorMessage() const {
    return errorMessage_;
  }

  void setErrorMessage(const string& errMsg) {
    errorMessage_ = errMsg;
  }

  ErrorType getErrorType() const {
    return errorType_;
  }

  void setErrorType(ErrorType errorType) {
    errorType_ = errorType;
  }

  const string& getRequestId() const {
    return requestId_;
  }

  void setRequestId(const string& requestId) {
    requestId_ = requestId;
  }

 private:

  string requestId_;

  string errorCode_;

  string errorMessage_;

  ErrorType errorType_;
};

}  // namespace exceptions

}  // namespace aliyun

#endif /* CORE_EXCEPTIONS_CLIENTEXCEPTION_H_ */
